<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');
if($_POST['act']=='add'){
		$uname = trim($_POST['uname']);
		$db->query('select * from ld_user_info where uname = \''.$uname.'\'',2);
		if(empty($db->rs)) show_automsg('您输入的用户账号未注册',YMCURL.'controllist',1);
		$arr['uname']= $uname;
		
		$arr['depict']=trim($_POST['depict']);
		$arr['role']=$_POST['role'];
		$arr['password']=getpwd($GLOBALARR['syadminpwd']);
		$arr['admin_status']= 0;
		
		
		if(empty($arr['role'])) show_automsg('请选择一个角色',YMCURL.'controllist',1);
		
		if($arr['role']==1){
			show_automsg('不能分派此角色!',$GLOBALARR['curl'],1);
		}

		$sql = getinsertsql($arr,'ld_user');

		$db->sitedbexec($sql);
		record_log('添加管理'.$uname);
		show_automsg('添加管理成功！',YMCURL.'controllist');
}




echo '<h3>管理添加</h3>';
echo '<div class="main-r-body"><form method="post" action="'.geturl().'">
		<div class="main-r-item"><a href="'.YMCURL.'controllist" class="thabtn">返回管理列表</a><input type="submit" class="thabtn" value="提交"></div>
		<input type="hidden" name="act" value="add"><input type="hidden" name="edid" value="'.$db->rs['uid'].'">';
echo '<table class="tregtab ttab">';
echo '	<tr>
			<td class="wdb20 alignr paddingr">会员账号</td>
			<td class="alignl paddingl"><input type="text" name="uname" value="" class="thconfig wd400">&nbsp;管理员账号必须是已注册过的会员!</td>
		</tr>';

echo '	<tr>
			<td class="wdb20 alignr paddingr">描述</td>
			<td class="alignl paddingl"><input type="text" name="depict" value="" class="thconfig wd400"></td>
		</tr>';		
echo '	<tr>
			<td class="wdb20 alignr paddingr" valign="top" >指派角色</td>
			<td class="alignl paddingl">';
echo '<select name="role" class="thconfig" style="color:#fff;text-indent:0;background:#272822;line-height:30px;height:30px">';
$db->query('select * from ld_privilege where `status`=0');
foreach ($db->rs as $k => $v) {

echo '<option value="'.$v['edid'].'" '.geteqval(array($role,$v['edid'],'selected','')).'>'.$v['rolename'].'</option>';
}
echo '</select>';
echo '		</td>
		</tr>';		
echo '</table>';
echo '</form></div>';		

?>